package com.xiaoshuidi.cloud.module.member.controller.admin.index.vo;

import com.alibaba.fastjson.JSONObject;
import com.xiaoshuidi.cloud.module.member.enums.AppIndexPageItemEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

@Data
public class SetAppIndexConfigVo {

    @Schema(description = "配置项id")
    private Long id;

    @Schema(description = "序号")
    private Integer indexId;

    @Schema(description = "推荐位名称")
    private String itemName;

    @Schema(description = "操作用户名称")
    private String userName;

    @Schema(description = "banner 列表")
    private BannerVo bannerVo;

    @Schema(description = "服务电话")
    private ServicePhoneVo servicePhoneVo;

    @Schema(description = "金刚位")
    private RecommendVo recommendVo;

    @Schema(description = "公寓推荐")
    private ResourceVo resourceVo;

    public String getConfigJson() {
        if(AppIndexPageItemEnum.BANNER.getIndex().equals(indexId)){
            return JSONObject.toJSONString(bannerVo);
        }
        if(AppIndexPageItemEnum.SERVICE_PHONE.getIndex().equals(indexId)){
            return JSONObject.toJSONString(servicePhoneVo);
        }
        if(AppIndexPageItemEnum.RECOMMEND.getIndex().equals(indexId)){
            return JSONObject.toJSONString(recommendVo);
        }
        if(AppIndexPageItemEnum.RESOURCE.getIndex().equals(indexId)){
            return JSONObject.toJSONString(resourceVo);
        }
        return "{}";
    }
}
